package net.mcreator.toolsasfood.procedures;

import net.minecraft.world.level.block.state.properties.Property;
import net.minecraft.world.level.block.state.BlockState;
import net.minecraft.world.level.block.Blocks;
import net.minecraft.world.level.LevelAccessor;
import net.minecraft.core.BlockPos;

import java.util.Map;

public class TurnsLavaProcedure {
	public static void execute(LevelAccessor world, double x, double y, double z) {
		BlockPos pos = new BlockPos((int) x, (int) y, (int) z);
		for(BlockPos blockpos : BlockPos.betweenClosed(pos.offset(-2,-1,-2),pos.offset(2,2,2))){
			
			if (Blocks.LAVA == (world.getFluidState(blockpos).createLegacyBlock()).getBlock()) {
			{
				BlockPos _bp = blockpos;
				BlockState _bs = Blocks.MAGMA_BLOCK.defaultBlockState();
				BlockState _bso = world.getBlockState(_bp);
				for (Map.Entry<Property<?>, Comparable<?>> entry : _bso.getValues().entrySet()) {
					Property _property = _bs.getBlock().getStateDefinition().getProperty(entry.getKey().getName());
					if (_property != null && _bs.getValue(_property) != null)
						try {
							_bs = _bs.setValue(_property, (Comparable) entry.getValue());
						} catch (Exception e) {
						}
				}
				world.setBlock(_bp, _bs, 3);
			}
			AfterthenProcedure.execute(world,blockpos.getX(),blockpos.getY(),blockpos.getZ());
			}
		}
		
	}
}
